//
//  VKServerXYCell.m
//  V-Learn
//
//  Created by liubo on 2019/1/18.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "VKStudyCollectCell.h"

@implementation VKStudyCollectCell{
    UIImageView *_imageV;
    UILabel *_contentLabel;
    UILabel *_titleLabel;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    VKStudyCollectCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VKStudyCollectCell"];
    if (cell == nil) {
        cell = [[VKStudyCollectCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"VKStudyCollectCell"];
    }
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 点击cell的时候不要变色
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        
        // 布局子控件
        [self autoLayout];
    }
    return self;
}

-(void)setModel:(VKStudyCollectModel *)model{
    _model = model;
    _contentLabel.text = model.protocolContent;
    if (model.row == 0) {
        _titleLabel.text = @"如何打卡";
    }else if (model.row == 1){
        _titleLabel.text = @"打卡要求";
    }else if(model.row == 2){
        _titleLabel.text = @"分享";
    }else if (model.row == 3){
        _titleLabel.text = @"打卡规则";
    }
}

- (void)autoLayout{
    
    UIImageView *leftImageV = [[UIImageView alloc]init];
    leftImageV.image = [UIImage imageNamed:@"vkleft"];
    [self.contentView addSubview:leftImageV];
    [leftImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.width.equalTo(@6);
        make.top.equalTo(@10);
        make.height.equalTo(@20);
    }];
    
    
    UILabel *titleLabel = [[UILabel alloc]init];
    _titleLabel = titleLabel;
    titleLabel.numberOfLines = 0;
    [self.contentView addSubview:titleLabel];
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.font = [UIFont systemFontOfSize:16];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(leftImageV);
        make.left.mas_equalTo(leftImageV.mas_right).offset(10);
    }];
    
    UILabel *contentLabel = [[UILabel alloc]init];
    _contentLabel = contentLabel;
    contentLabel.numberOfLines = 0;
    [self.contentView addSubview:contentLabel];
    contentLabel.textColor = [UIColor cz_colorWithRed:102 green:102 blue:102];
    contentLabel.font = [UIFont systemFontOfSize:16];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).offset(15);
        make.right.mas_equalTo(self.contentView).offset(-15);
        make.top.mas_equalTo(leftImageV.mas_bottom).offset(10);
        make.bottom.mas_equalTo(self.contentView.mas_bottom);
    }];
    
//    UIView *lineView = [[UIView alloc]init];
//    [self.contentView addSubview:lineView];
//    lineView.backgroundColor = [UIColor cz_colorWithRed:244 green:244 blue:244];
//    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.right.equalTo(@0);
//        make.height.equalTo(@1);
//        make.bottom.mas_equalTo(self.contentView);
//    }];
    
    
}

@end
